const BaseController = require('./base');


class SettingController extends BaseController {
  async updateDocxFile() {
    const { ctx } = this;
    const file = ctx.request.files[0];
    if (!file) {
      return this.fail('请选择文件');
    }
    const updateRes = await ctx.service.setting.updateDocxFile(file);
    if (updateRes) {
      return this.success('更新成功');
    }
    return this.fail('上传失败');
  }

  async getDocxFile() {
    const { ctx } = this;
    const docxFile = await ctx.service.setting.getDocxFile();
    if (docxFile) {
      return this.success(docxFile);
    }
    return this.fail('获取失败');
  }
}

module.exports = SettingController;
